using System;
using System.Data;
using System.Data.SqlClient;
using NNS.Framework;
using QLTB.BusinessObjects;

namespace QLTB.DataAccess
{
    /// <summary>
    /// Project: NNS System 
    /// Generated Class for Table : TBL_DONVI.
    /// Date: 6/24/2010
    /// Author: Trần Hoàng Tâm
    /// </summary>
    public class TBL_DONVIDA : Object
    {
        #region Get

        public TBL_DONVI Get(
            int MaDonVi)
        {
            TBL_DONVI ob = null;
            SqlDataReader myReader = SqlHelper.Helper.ExecuteReader(CommandType.StoredProcedure, "TBL_DONVI_Get",
                                                                    new[] {new SqlParameter("@MaDonVi", MaDonVi)});
            if (myReader != null)
            {
                while (myReader.Read())
                {
                    ob = Populate(myReader);
                }
                myReader.Close();
                myReader.Dispose();
            }
            SqlHelper.Helper.Close();

            return ob;
        }

        #endregion

        #region Populate

        public TBL_DONVI Populate(
            IDataReader myReader)
        {
            TBL_DONVI obj = null;
            if (myReader != null)
            {
                obj = new TBL_DONVI();
                if (!myReader.IsDBNull(myReader.GetOrdinal("MaDonVi")))
                {
                    obj.MaDonVi = Convert.ToInt32(myReader["MaDonVi"]);
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("TenDonVi")))
                {
                    obj.TenDonVi = Convert.ToString(myReader["TenDonVi"]);
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("IPClass")))
                {
                    obj.IPClass = Convert.ToString(myReader["IPClass"]);
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("MaCapTren")))
                {
                    obj.MaCapTren = Convert.ToInt32(myReader["MaCapTren"]);
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("Diachi")))
                {
                    obj.Diachi = Convert.ToString(myReader["Diachi"]);
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("DienThoai")))
                {
                    obj.DienThoai = Convert.ToString(myReader["DienThoai"]);
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("CapDonvi")))
                {
                    obj.CapDonvi = Convert.ToInt32(myReader["CapDonvi"]);
                }
            }
            return obj;
        }

        #endregion
    }
}